<div class="layui-form" lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit"
    style="padding: 20px -30px 0 0;">
    <script type='text/html' template lay-done="layui.data.formdone(d.params)">
        <input type='hidden' name='PID' id="PID" />
    </script>
    <input type='hidden' name='BillCode' id="BillCode" />
    <div style="padding: 0px;">

        <fieldset class="layui-elem-field layui-field-title">
            <legend>交易单信息</legend>
        </fieldset>
        <div class="layui-row layui-col-space15">
            <div class='layui-form-item'>
                <label class='layui-form-label'>交易单号</label>
                <div class='layui-input-inline'>
                    <script type='text/html' template>
                        <input type='text' name='Code' value='{{ d.params.Code || '' }}' readonly="readonly" lay-verify='required' placeholder='交易单号' autocomplete='off' class='layui-input'>
                    </script>
                </div>
            </div>

            <div class='layui-form-item'>
                <label class='layui-form-label'>总金额</label>
                <div class='layui-input-inline'>
                    <script type='text/html' template>
                        <input type='text' name='Money' value='{{ d.params.Money || '' }}' readonly="readonly" lay-verify='required' placeholder='交易金额' autocomplete='off' class='layui-input'>
                    </script>
                </div>
            </div>
        </div>


        <fieldset class="layui-elem-field layui-field-title">
            <legend>订单信息</legend>
        </fieldset>
        <div class="layui-card-body">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <table id="LAY-app-content-listbillsq" lay-filter="LAY-app-content-listbillsq"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <div id="changeFarePriceDiv" style="display:none">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>修改运费</legend>
            </fieldset>

            <div class="layui-row layui-col-space15">
                <div class='layui-form-item'>
                    <label class='layui-form-label'>修改运费</label>
                    <div class='layui-input-inline'>
                        <script type='text/html' template>
                            <input type='text' name='FarePrice' lay-verify='required' placeholder='修改运费' autocomplete='off' class='layui-input'>
                        </script>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" value="确认"
                               class="layui-btn">
                    </div>

                    <!-- <div class="layui-input-inline">
                <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" value="预览修改之后运费"
                    class="layui-btn">
            </div> -->
                </div>
            </div>
        </div>
    </div>

    <script>

        layui.data.formdone = function (params) {


            layui.use(['admin', 'table', 'element', 'laydate', 'formSelects'], function () {
                var $ = layui.$
                    , admin = layui.admin
                    , view = layui.view
                    , table = layui.table
                    , form = layui.form;

                if (params.State_Sel == 0) {
                    $("#changeFarePriceDiv").show();
                }

                var colsdata = [[
                    //{ type: 'checkbox', fixed: 'left', field: 'PID' }, //sort: true  //hide: true //  width:100
                    { field: 'OrderNumber', title: '订单号' },
                    { field: 'UserName', title: '收货人' },
                    { field: 'OrderPrice', title: '订单价格' },
                    { field: 'FarePrice', title: '运费' },
                    { field: 'DiscountPrice', title: '优惠价格' },
                    { field: 'PayPrice', title: '支付金额' },

                ]]

                table.render({
                    elem: "#LAY-app-content-listbillsq"
                    , toolbar: false  //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                    , defaultToolbar: ['filter']
                    , method: "post"
                    , url: layui.setter.APIUrl + '/Shop/BillflowMgr/getBillCodeByOrder'
                    , where: { OrderId: params.PID }
                    , headers: { //通过 request 头传递
                        Authorization: "bearer " + layui.data('layuiAdmin').access_token
                    }
                    , parseData: function (res) { //res 即为原始返回的数据 
                        var data = res.Data.billmodel;
                        form.val("layuiadmin-app-form-submit", {
                            "Code": data.Code,
                            "Money": data.Money,
                            "BillCode":data.PID
                        });

                        return {
                            "ResultCode": res.ResultCode, //解析接口状态
                            "ResultInfo": res.ResultInfo, //解析提示文本
                            "count": res.Data.list.length, //解析数据长度
                            "Data": res.Data.list //解析数据列表 
                        };
                    }
                    , cols: colsdata
                    , page: false
                    , limit: 100
                    , limits: [10, 15, 20, 25, 30]
                    , text: {
                        none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增 text: '对不起，加载出现异常！'
                    }
                });

            });

        }

        layui.use(['admin', 'table', 'element', 'laydate', 'formSelects'], function () {

        });



    </script>